#ifndef QQ_EMOJI_DELEGATE
#define QQ_EMOJI_DELEGATE

#include <qtimer.h>
#include <qpainter.h>
#include <qpainterpath.h>
#include <qstyleditemdelegate.h>
#include <qevent.h>
#include <qdebug.h>

#include "chat/QQEmojiModel.h"

class QQEmojiDelegate : public QStyledItemDelegate
{
	Q_OBJECT
public:
	QQEmojiDelegate(QObject* parent = nullptr);
	~QQEmojiDelegate();
	void setItemSize(QSize size);
	QSize getItemSize() const;
protected:
	void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
	QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override;
	bool editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index) override;
private slots:
	void onFrameTimeout();
private:
	QPersistentModelIndex mPersistIndex;
	QSize mItemSize;
	QTimer* mFrameTimer;
	mutable int mCurrentFrame;
	int mTotalFrames;
};

#endif